From dcdbb6a90353231497273d3062c2cd5d396e1d6e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 3 Aug 2022 17:35:31 -0600 Subject: [PATCH] convert html writer to html 5. (#905) this also fixes a bug where we could fail to entitize wpt->description. this also fixes a bug where we could create illegal fragments and id attributes. --- html.cc | 81 +++++++++++++++++++++-------------- html.h | 3 ++ reference/gc/GC7FA4.html | 63 +++++++++++++++------------ reference/gc/GCGCA8.html | 53 +++++++++++++---------- reference/gc/GCGCA8_logs.html | 69 ++++++++++++++++------------- 5 files changed, 159 insertions(+), 110 deletions(-) diff --git a/html.cc b/html.cc index 4619040ad..0359a49a2 100644 --- a/html.cc +++ b/html.cc @@ -57,6 +57,13 @@ HtmlFormat::wr_deinit() mkshort_del_handle(&mkshort_handle); } +QString HtmlFormat::create_id(int sequence_number) +{ + // It's easier to create a legal fragment and identifer from scratch than + // from user supplied text. + return QStringLiteral("WPT%1").arg(sequence_number, 3, 10, QChar('0')); +} + void HtmlFormat::html_disp(const Waypoint* wpt) const { @@ -69,10 +76,12 @@ HtmlFormat::html_disp(const Waypoint* wpt) const GPS_Math_WGS84_To_UTM_EN(wpt->latitude, wpt->longitude, &utme, &utmn, &utmz, &utmzc); - *file_out << "\nshortname << "\">
\n"; - *file_out << "\n"; + *file_out << "

\n"; + *file_out << "
\n"; QString sn = global_opts.synthesize_shortnames ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname; - *file_out << "\n"; + *file_out << " \n"; + *file_out << "

\n"; + *file_out << " \n"; - *file_out << "\n"; + *file_out << " \n"; + *file_out << " \n"; - *file_out << "\n"; + *file_out << " \n"; - *file_out << "

" << sn << " - "; + *file_out << "

\n"; + *file_out << "

" << sn << " - "; *file_out << QStringLiteral("%1 (%2%3 %4 %5)") .arg(pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", true)) .arg(utmz) @@ -89,35 +98,38 @@ HtmlFormat::html_disp(const Waypoint* wpt) const *file_out << "GetUrlLink().url_ << "\">" << html_entitize(wpt->description) << ""; } else { - *file_out << wpt->description; + *file_out << html_entitize(wpt->description); } if (!wpt->gc_data->placer.isEmpty()) { *file_out << " by " << wpt->gc_data->placer; } } - *file_out << "

"; + *file_out << " \n"; if (wpt->gc_data->terr) { - *file_out << QStringLiteral("

%1%2 / %3%4
\n") + *file_out << QStringLiteral("

%1%2 / %3%4
\n") .arg((int)(wpt->gc_data->diff / 10)) .arg((wpt->gc_data->diff%10) ? "½" : "") .arg((int)(wpt->gc_data->terr / 10)) .arg((wpt->gc_data->terr%10) ? "½" : ""); *file_out << gs_get_cachetype(wpt->gc_data->type) << " / " - << gs_get_container(wpt->gc_data->container) << "

"; + << gs_get_container(wpt->gc_data->container) << "

\n"; } - *file_out << "
"; + *file_out << "
\n"; if (!wpt->gc_data->desc_short.utfstring.isEmpty()) { - *file_out << "

" - << strip_nastyhtml(wpt->gc_data->desc_short.utfstring) << "

\n"; + *file_out << "

" + << strip_nastyhtml(wpt->gc_data->desc_short.utfstring) << "

\n"; } if (!wpt->gc_data->desc_long.utfstring.isEmpty()) { - *file_out << "

" - << strip_nastyhtml(wpt->gc_data->desc_long.utfstring) << "

\n"; + *file_out << "

" + << strip_nastyhtml(wpt->gc_data->desc_long.utfstring) << "

\n"; } if (!wpt->gc_data->hint.isEmpty()) { QString hint; @@ -126,10 +138,10 @@ HtmlFormat::html_disp(const Waypoint* wpt) const } else { hint = wpt->gc_data->hint; } - *file_out << "

Hint: " + *file_out << "

Hint: " << hint << "

\n"; } else if (!wpt->notes.isEmpty() && (wpt->description.isEmpty() || wpt->notes != wpt->description)) { - *file_out << "

" << wpt->notes << "

\n"; + *file_out << "

" << wpt->notes << "

\n"; } if (includelogs) { @@ -139,7 +151,7 @@ HtmlFormat::html_disp(const Waypoint* wpt) const xml_tag* curlog = xml_findfirst(root, "groundspeak:log"); while (curlog) { time_t logtime = 0; - *file_out << "

\n"; + *file_out << "

\n"; xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type"); if (logpart) { @@ -193,15 +205,18 @@ HtmlFormat::html_disp(const Waypoint* wpt) const } } } - *file_out << "

\n"; + *file_out << " \n"; + *file_out << " \n"; + *file_out << " \n"; + *file_out << " \n"; } void HtmlFormat::html_index(const Waypoint* wpt) const { - *file_out << QStringLiteral("%1 - %2
\n") - .arg(html_entitize(wpt->shortname), html_entitize(wpt->description)); + *file_out << " " + << html_entitize(wpt->shortname) << " - " << html_entitize(wpt->description) + << "
\n"; } void @@ -209,41 +224,45 @@ HtmlFormat::write() { setshort_length(mkshort_handle, 6); - *file_out << "\n"; + *file_out << "\n"; *file_out << "\n"; *file_out << "\n"; - *file_out << " \n"; + *file_out << " \n"; // Don't write this line when running test suite. Actually, we should // probably not write this line at all... if (!gpsbabel_testmode()) { - *file_out << " \n"; } - *file_out << " GPSBabel HTML Output\n"; + *file_out << " GPSBabel HTML Output\n"; if (stylesheet) { - *file_out << " \n"; } else { - *file_out << " \n"; + *file_out << " \n"; } *file_out << "\n"; *file_out << "\n"; - *file_out << "

\n"; + *file_out << "

\n"; auto html_index_lambda = [this](const Waypoint* waypointp)->void { + waypoint_number++; html_index(waypointp); }; + waypoint_number = 0; waypt_disp_all(html_index_lambda); - *file_out << "

\n"; + *file_out << "

\n"; auto html_disp_lambda = [this](const Waypoint* waypointp)->void { + waypoint_number++; html_disp(waypointp); }; + waypoint_number = 0; waypt_disp_all(html_disp_lambda); *file_out << "\n"; diff --git a/html.h b/html.h index d80623241..86e16ada4 100644 --- a/html.h +++ b/html.h @@ -65,6 +65,7 @@ public: private: /* Member Functions */ + static QString create_id(int sequence_number); void html_disp(const Waypoint* wpt) const; void html_index(const Waypoint* wpt) const; @@ -73,6 +74,8 @@ private: gpsbabel::TextStream* file_out{nullptr}; short_handle mkshort_handle{}; + int waypoint_number{}; + char* stylesheet = nullptr; char* html_encrypt = nullptr; char* includelogs = nullptr; diff --git a/reference/gc/GC7FA4.html b/reference/gc/GC7FA4.html index bf2d18466..da6431275 100644 --- a/reference/gc/GC7FA4.html +++ b/reference/gc/GC7FA4.html @@ -1,26 +1,33 @@ - + - - GPSBabel HTML Output - + + GPSBabel HTML Output + -

-GC7FA4 - Points géodésiques du Québec
-

- -
- - - - + +

GC7FA4 - N46°08.000 W73°00.000 (18T 654491 5110806)
-Points géodésiques du Québec by Sverdrup2

1 / 1
-Locationless (Reverse) Cache / Virtual

LES COORDONÉES PUBLIÉES NE REPRÉSENTENT PAS LA LOCALISATION D'UNE CACHE -PUBLISHED COORDINATES DO NOT REPRESENT THE LOCALIZATION OF A CACHE

-

Le but de cette cache virtuelle est de trouver les points géodésiques du territoire québécois. Les points géodésiques sont faciles à identifier (capuchons de laiton au niveau du sol). Généralement, il y a un panneau de couleur orange sur un poteau à proximité du point. Sur ce panneau, le numéro du point est identifié. Aussi, la distance relative du panneau au point est indiquée. +

+ GC7FA4 - Points géodésiques du Québec
+

+

+ + + + + + + -
+

GC7FA4 - N46°08.000 W73°00.000 (18T 654491 5110806)
+Points géodésiques du Québec by Sverdrup2

+
+

1 / 1
+Locationless (Reverse) Cache / Virtual

+
+

LES COORDONÉES PUBLIÉES NE REPRÉSENTENT PAS LA LOCALISATION D'UNE CACHE +PUBLISHED COORDINATES DO NOT REPRESENT THE LOCALIZATION OF A CACHE

+

Le but de cette cache virtuelle est de trouver les points géodésiques du territoire québécois. Les points géodésiques sont faciles à identifier (capuchons de laiton au niveau du sol). Généralement, il y a un panneau de couleur orange sur un poteau à proximité du point. Sur ce panneau, le numéro du point est identifié. Aussi, la distance relative du panneau au point est indiquée.

Pour inscrire votre découverte, vous devez prendre en note le NUMÉRO DU POINT(inscrit sur le point même ou au centre du panneau)LA COORDONNÉE(en format HDDD MM.MM WGS84 datum ET UTM NAD83 indiquer la zone SVP)et L'ALTITUDE RELATIVE. Si le points n'est pas visible (il se peut qu'il soit sous quelques centimètres de terre) vous pouvez prendre la coordonnée à l'emplacement du panneau SI LA PRÉCISION DE VOTRE GPS EST SUPÉRIEUR À LA DISTANCE INSCRITE SUR LE PANNEAU (ex : Précison du GPS de 5m et distance au point inscrite sur le panneau de 3m).

@@ -54,8 +61,8 @@ And all old names of ministries and/or organization

PICTURES of points and of the panels will follow soon. YOU CAN ONLY LOG ONE POINT (ONE POINT PER GEOCACHER) -Good luck!

-

+Good luck!

+

Found it by Christopher R & Pooh B on 2005-07-12
N48°10.207 W53°58.097
This marker is not in Quebec but it is a Geodesic marker in Clarenville, Newfoundland, Canada! @@ -69,7 +76,7 @@ Smiles Pooh Bear Ce marqueur n'est pas au Québec mais c'est un marqueur géodésique dans Clarenville, Terre-Neuve, Canada! A trouvé celui-ci tandis que chasse une cachette traditionnelle et pensé à cette cachette tout de suite! Elle est située sur la montagne nue dans Clarenville - il y a aactually deux marqueurs à moins de 15 pieds d'un des autres sur la montagne nue... Ours De Pooh De Sourires

-

+

Found it by TravelBen on 2005-06-26
N45°26.872 W73°56.410
[:D] 14h22 @@ -83,7 +90,7 @@ UTM: 18T E 582877 N 5033250 Ce marqueur se trouve dans le ville de Senneville, sur un monument décrivant une page d'histoire du Québec, sur le bas côté avant droit. Près de la cache: Exo-07 La Jumelle de Loudiver (GCP3VE)

-

+

Found it by etasse on 2005-06-03
N45°29.525 W75°43.005
MRN marker 94K4731 in Gatineau, QC. corner of Du Rhone and Gatineau Ave. @@ -99,18 +106,20 @@ UTM 18T 0443996 5037868 This pole has everything: An underground cable warning, a geodesic mark, a bus stop and a garage sale sign. Judging by the coordinates it looks like the coords should be 45°29'31.5" -75°43'0" I placed the GPS antenna right against the marker, to no avail.

-

+

Found it by Katou on 2005-06-03
N46°37.091 W71°55.974
Un bo point géodésique a Lotbinière..en allant faire une nouvelle cache a l'île richelieu ;-)

-

+

Found it by Gps_Gulliver&DauphinBleu on 2005-05-29
N45°32.449 W73°30.747
Point Geodesique situe near Port de Plaisance de Longueuil sur le bord du fleuve st-laurent. Il y a des sentiers et une grande piste cyclable Enjoy !

-
+
+ diff --git a/reference/gc/GCGCA8.html b/reference/gc/GCGCA8.html index 8f7bcadbc..3ab173bf0 100644 --- a/reference/gc/GCGCA8.html +++ b/reference/gc/GCGCA8.html @@ -1,25 +1,32 @@ - + - - GPSBabel HTML Output - + + GPSBabel HTML Output + -

-GCGCA8 - Oozy rat in a sanitary zoo
-

- -
- - - - + +

GCGCA8 - N35°55.300 W86°51.700 (16S 512480 3975269)
-Oozy rat in a sanitary zoo by robertlipe

3 / 2
-Unknown Cache / Unknown

The cache is not at the coordinates above. These coords will get you to the correct park and within 1/2 mile of the cache. The cache is within 35 feet of the trail. It is not handicapped accessible. It is a nice walk in the woods that is practical for all ages. There is no space in the container for trading items. You should bring a writing stick and bug spray is recommended.

-

So if the cache isn't at the above coordinates, where is it? +

+ GCGCA8 - Oozy rat in a sanitary zoo
+

+

+ + + + + + + Now that it's intuitively obvious to even the most casual observer where the cache is, turn on your geo-mojo and go find it.
-Member of Middle Tennessee GeoCachers Club [www.mtgc.org]

-

Hint: There Is No Hint

- -
+

GCGCA8 - N35°55.300 W86°51.700 (16S 512480 3975269)
+Oozy rat in a sanitary zoo by robertlipe

+
+

3 / 2
+Unknown Cache / Unknown

+
+

The cache is not at the coordinates above. These coords will get you to the correct park and within 1/2 mile of the cache. The cache is within 35 feet of the trail. It is not handicapped accessible. It is a nice walk in the woods that is practical for all ages. There is no space in the container for trading items. You should bring a writing stick and bug spray is recommended.

+

So if the cache isn't at the above coordinates, where is it?

    @@ -34,9 +41,11 @@ Unknown Cache / Unknown

+Member of Middle Tennessee GeoCachers Club [www.mtgc.org]

+

Hint: There Is No Hint

+
+ diff --git a/reference/gc/GCGCA8_logs.html b/reference/gc/GCGCA8_logs.html index 5f75d6975..1ec4de1ac 100644 --- a/reference/gc/GCGCA8_logs.html +++ b/reference/gc/GCGCA8_logs.html @@ -1,25 +1,32 @@ - + - - GPSBabel HTML Output - + + GPSBabel HTML Output + -

-GCGCA8 - Oozy rat in a sanitary zoo
-

- -
- - - - + +

GCGCA8 - N35°55.300 W86°51.700 (16S 512480 3975269)
-Oozy rat in a sanitary zoo by robertlipe

3 / 2
-Unknown Cache / Unknown

The cache is not at the coordinates above. These coords will get you to the correct park and within 1/2 mile of the cache. The cache is within 35 feet of the trail. It is not handicapped accessible. It is a nice walk in the woods that is practical for all ages. There is no space in the container for trading items. You should bring a writing stick and bug spray is recommended.

-

So if the cache isn't at the above coordinates, where is it? +

+ GCGCA8 - Oozy rat in a sanitary zoo
+

+

+ + + + + + + Now that it's intuitively obvious to even the most casual observer where the cache is, turn on your geo-mojo and go find it.
-Member of Middle Tennessee GeoCachers Club [www.mtgc.org]

-

Hint: There Is No Hint

-

+Member of Middle Tennessee GeoCachers Club [www.mtgc.org]

+

Hint: There Is No Hint

+

Found it by littlepod on 2005-07-03
Enjoyed the puzzle. We seemed to be about 50ft off though. TFTC.

-

+

Write note by robertlipe on 2005-04-29
TB Drop to show he's hanging out in Nashville until we blast off for Geowoodstock in a few weeks.

-

+

Found it by Big Bumblebee on 2005-04-18
Found it a while ago. Thanks.

-

+

Write note by robertlipe on 2005-03-27
I had to renew my permit with the CDC and in doing so, I trolled out here verified that the infectious ooze is fully within specification and industry accepted tolerance. Ooze On!

-

+

Found it by Virtual Babe on 2004-12-27
This was a great cache, however on this day I considered it a FIFM cache (Fun, Invigorating, Frustrating and Maddening), especially when the cache was not replaced in the proper spot by the previous cacher! Thanks anyway!!

-

+

Write note by robertlipe on 2004-01-12
I got a complaint from the CDC about oozy rat this weekend. I went out tonight in the dark and verified that the infectious ooze is fully within specification and industry accepted tolerance. (Although I realize now I did misstate the cache container to the reporting officer when confronted. It's, uuuuh, smaller than I said.)

-

+

Write note by robertlipe on 2003-10-04
In the expectation that this cache will get some traffic in the next 48 hours, Ryan and I checked it earlier today. The Rat is Oozing just as we planned it.

-

+

Write note by robertlipe on 2003-07-03
It won't earn him a smiley face, but I've confirmed that rickrich would have indeed sunk the battleship! Thanx for playing. You get a copy of the home game and some rice-a-roni...

- -
+

GCGCA8 - N35°55.300 W86°51.700 (16S 512480 3975269)
+Oozy rat in a sanitary zoo by robertlipe

+
+

3 / 2
+Unknown Cache / Unknown

+
+

The cache is not at the coordinates above. These coords will get you to the correct park and within 1/2 mile of the cache. The cache is within 35 feet of the trail. It is not handicapped accessible. It is a nice walk in the woods that is practical for all ages. There is no space in the container for trading items. You should bring a writing stick and bug spray is recommended.

+

So if the cache isn't at the above coordinates, where is it?

    @@ -34,33 +41,35 @@ Unknown Cache / Unknown

+
+ -- 2.30.2